import tkinter as tk
import tkinter
print(tkinter.TkVersion)

# 创建主窗口
root = tk.Tk()
root.title("json 转 model")

# 创建文本标签
text_label = tk.Label(root, text="这是文本标签", font=("Arial", 16))
text_label.pack()

# 创建按钮
button = tk.Button(root, text="点击我", font=("Arial", 12), command=lambda: print("你点击了按钮！"))
button.pack()




variable = tk.StringVar()
variable.set("one")



def callback():
    # 在这里编写你的回调代码
    print("你选择了选项：", drop_down.get())
    
# 创建下拉选择器
drop_down = tk.OptionMenu(root, "下拉选择器", "选项 1", "选项 2", "选项 3")
# drop_down.config(command=callback)
drop_down.pack()

w = tk.OptionMenu(root, variable, "one", "two", "three")
w.pack()
list1 = ["青菜", "白菜", "菠菜", "黄瓜"]
e = tk.OptionMenu(root, variable, *list1)
e.pack()

def A():
    print("点击调用",variable.get())
tk.Button(root,text="获取文本值",command=A).pack()
root.geometry("800x600+500+500")



# menuCall
def menuCall():

    print("点击调用")

root.title('hello thinter')
height= root.winfo_screenheight()
width= root.winfo_screenwidth()
# root.geometry('400x300+%d+%d'%((width-400)/2,(height-300)/2))

mb = tk.Menubutton(root, text="点我", relief="raised")
mb.pack()

filemenu = tk.Menu(mb, tearoff=False)
filemenu.add_checkbutton(label="打开", command=menuCall, selectcolor="yellow")
filemenu.add_command(label="保存", command=menuCall)
filemenu.add_separator()
filemenu.add_command(label="退出", command=root.quit)
mb.config(menu=filemenu)

tk.Button(root,text="获取menu文本值",command=menuCall).pack()

# 主循环
root.mainloop()

